from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from backend.app.routers import auth, users, ppt, callback, token
from backend.app.routers import ppt_routes  # 添加新的PPT路由
from backend.app.routers.token import lifespan

app = FastAPI(lifespan=lifespan)

# 配置 CORS
app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

# 注册路由
app.include_router(auth.router, prefix="/api", tags=["认证"])
app.include_router(users.router, prefix="/api", tags=["用户"])
app.include_router(ppt.router, prefix="/api", tags=["PPT"])
app.include_router(callback.router, prefix="/api", tags=["回调"])
app.include_router(ppt_routes.router, prefix="/api", tags=["PPT转换"])  # 注册新路由
app.include_router(token.router, prefix="/api", tags=["Token"])  # 注册Token路由